 package tools.packet;

 import client.MapleCharacter;
 import constants.SkillConstants;
 import handling.opcode.SendPacketOpcode;
 import java.awt.Point;
 import java.util.List;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import server.maps.MapleDragon;
 import server.maps.MapleLittleWhite;
 import server.maps.MapleSummon;
 import server.movement.LifeMovementFragment;
 import tools.AttackPair;
 import tools.Pair;
 import tools.data.output.MaplePacketLittleEndianWriter;










 public class SummonPacket
 {
/*  29 */   private static final Logger log = LogManager.getLogger(SummonPacket.class);

   public static byte[] spawnSummon(MapleSummon summon, boolean animated) {
/*  32 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/*  33 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/*  35 */     mplew.writeShort(SendPacketOpcode.SPAWN_SUMMON.getValue());
/*  36 */     mplew.writeInt(summon.getOwnerId());
/*  37 */     mplew.writeInt(summon.getObjectId());
/*  38 */     mplew.writeInt(summon.getSkillId());
/*  39 */     mplew.writeInt(summon.getOwnerLevel());
/*  40 */     mplew.writeInt(summon.getSkillLevel());
/*  41 */     mplew.writePos(summon.getPosition());
/*  42 */     mplew.write(summon.getStance());
/*  43 */     mplew.writeShort(summon.getFh());
/*  44 */     mplew.write(summon.getMovementType().getValue());
/*  45 */     mplew.write(summon.getAttackType());
/*  46 */     mplew.write(animated ? 1 : 0);
/*  47 */     if (summon.is大漩涡()) {
/*  48 */       mplew.writeInt(summon.getMobid());
     } else {
/*  50 */       if (summon.is机械磁场()) {
/*  51 */         mplew.write(0);
       }
/*  53 */       mplew.writeInt(0);
     }
/*  55 */     mplew.write(0);
/*  56 */     mplew.write(1);
/*  57 */     mplew.writeLong(0L);
/*  58 */     mplew.write(summon.showCharLook() ? 1 : 0);
/*  59 */     if (summon.showCharLook()) {
/*  60 */       PacketHelper.addCharLook(mplew, summon.getOwner(), true, false);
     }
/*  62 */     switch (summon.getSkillId()) {
       case 35111002:
/*  64 */         mplew.write(0);
         break;
       case 42111003:
       case 400041028:
       case 400051014:
/*  69 */         mplew.writeLong(0L);
         break;
       case 400051028:
/*  72 */         mplew.write(0);
         break;
       case 400051029:
       case 400051030:
       case 400051031:
       case 400051032:
/*  78 */         mplew.write(1);
         break;
     }
/*  81 */     int x = 0, y = 0;
/*  82 */     if (writeSummonPosition(summon.getSkillId())) {

/*  84 */       switch (summon.getSkillId()) {
         case 400031007:
/*  86 */           x = 300;
/*  87 */           y = 41000;
           break;

         case 400031008:
/*  91 */           x = 600;
/*  92 */           y = 41000;
           break;

         case 400031009:
/*  96 */           x = 900;
/*  97 */           y = 41000;
           break;

         case 14111024:
         case 131001017:
/* 102 */           x = 400;
/* 103 */           y = 30;
           break;

         case 14121055:
         case 131002017:
/* 108 */           x = 800;
/* 109 */           y = 60;
           break;

         case 14121056:
         case 131003017:
/* 114 */           x = 1200;
/* 115 */           y = 90;

         case 400011005:
/* 118 */           x = 60;
/* 119 */           y = 30;
           break;
       }

/* 123 */       mplew.writeInt(x);
/* 124 */       mplew.writeInt(y);
     }
/* 126 */     mplew.write(0);
/* 127 */     mplew.writeInt(summon.getDuration());
/* 128 */     mplew.write(1);
/* 129 */     mplew.writeInt((summon.getSkillId() == 400021071) ? 1 : 0);
/* 130 */     if (summon.getSkillId() >= 33001007 && summon.getSkillId() - 33001007 <= 8) {
/* 131 */       mplew.write(0);
/* 132 */       mplew.writeInt(0);
     }

/* 135 */     mplew.writeBool((summon.getSkillId() == 152101000));
/* 136 */     if (summon.getSkillId() == 152101000) {
/* 137 */       mplew.writeInt(0);
/* 138 */       mplew.writeInt(0);
/* 139 */       mplew.writeInt(0);
/* 140 */       for (int j = 0; j < Math.min(0, 3); j++) {
/* 141 */         mplew.writeInt(j + 1);
/* 142 */         mplew.writeInt(0);
       }
     }
/* 145 */     mplew.writeInt(SkillConstants.is猴子护卫队(summon.getSkillId()) ? 3 : 0);
/* 146 */     switch (summon.getSkillId()) {
       case 400051038:
       case 400051052:
       case 400051053:
/* 150 */         mplew.writeInt(400051038);
/* 151 */         mplew.writeInt(400051052);
/* 152 */         mplew.writeInt(400051053);
         break;
     }

/* 156 */     if (summon.getSkillId() == 42111101 || summon.getSkillId() == 42111102) {
/* 157 */       mplew.writeZeroBytes(3);
     }

/* 160 */     mplew.writeInt(0);
/* 161 */     return mplew.getPacket();
   }

   public static boolean writeSummonPosition(int skillId) {
/* 165 */     switch (skillId) {
       case 14111024:
       case 14121054:
       case 14121055:
       case 14121056:
       case 131001017:
       case 131002017:
       case 131003017:
       case 400011005:
       case 400031007:
       case 400031008:
       case 400031009:
       case 400041007:
/* 178 */         return true;
     }
/* 180 */     return false;
   }








   public static byte[] removeSummon(MapleSummon summon, boolean animated) {
/* 191 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 192 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 194 */     mplew.writeShort(SendPacketOpcode.REMOVE_SUMMON.getValue());
/* 195 */     mplew.writeInt(summon.getOwnerId());
/* 196 */     mplew.writeInt(summon.getObjectId());
/* 197 */     mplew.write(animated ? 4 : summon.getRemoveStatus());

/* 199 */     return mplew.getPacket();
   }















   public static byte[] moveSummon(int chrId, int oid, int v169, int tEncodedGatherDuration, Point startPos, Point velPos, List<LifeMovementFragment> moves) {
/* 217 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 219 */     mplew.writeShort(SendPacketOpcode.MOVE_SUMMON.getValue());
/* 220 */     mplew.writeInt(chrId);
/* 221 */     mplew.writeInt(oid);
/* 222 */     PacketHelper.serializeMovementList(mplew, v169, tEncodedGatherDuration, startPos, velPos, moves);
/* 223 */     return mplew.getPacket();
   }

   public static byte[] summonAttack(MapleSummon summon, byte animation, byte numAttackedAndDamage, List<AttackPair> allDamage, int level, boolean darkFlare) {
/* 227 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 229 */     mplew.writeShort(SendPacketOpcode.SUMMON_ATTACK.getValue());
/* 230 */     mplew.writeInt(summon.getOwnerId());
/* 231 */     mplew.writeInt(summon.getObjectId());
/* 232 */     mplew.writeInt(level);
/* 233 */     mplew.write(animation);
/* 234 */     mplew.write(numAttackedAndDamage);

/* 236 */     for (AttackPair attackEntry : allDamage) {
/* 237 */       if (attackEntry.attack != null) {
/* 238 */         mplew.writeInt(attackEntry.objectid);
/* 239 */         mplew.write(7);
/* 240 */         for (Pair<Long, Boolean> eachd : (Iterable<Pair<Long, Boolean>>)attackEntry.attack) {
/* 241 */           if (((Boolean)eachd.right).booleanValue()) {
/* 242 */             mplew.writeLong(((Long)eachd.left).longValue() + -2147483648L); continue;
           }
/* 244 */           mplew.writeLong(((Long)eachd.left).longValue());
         }
         continue;
       }
/* 248 */       mplew.writeLong(0L);
     }

/* 251 */     mplew.write(darkFlare ? 1 : 0);
/* 252 */     mplew.write(0);
/* 253 */     mplew.writePos(summon.getTruePosition());
/* 254 */     mplew.writeInt(0);
/* 255 */     mplew.writeInt(0);
/* 256 */     mplew.write(0);
/* 257 */     mplew.writeInt(0);
/* 258 */     return mplew.getPacket();
   }

   public static byte[] summonSkill(int chrId, int summonSkillid, int newStance) {
/* 262 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 263 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 265 */     mplew.writeShort(SendPacketOpcode.SUMMON_SKILL.getValue());
/* 266 */     mplew.writeInt(chrId);
/* 267 */     mplew.writeInt(summonSkillid);
/* 268 */     mplew.write(newStance);
/* 269 */     return mplew.getPacket();
   }

   public static byte[] damageSummon(int chrId, int summonSkillId, int damage, int unkByte, int monsterIdFrom) {
/* 273 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 274 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 276 */     mplew.writeShort(SendPacketOpcode.DAMAGE_SUMMON.getValue());
/* 277 */     mplew.writeInt(chrId);
/* 278 */     mplew.writeInt(summonSkillId);
/* 279 */     mplew.write(unkByte);
/* 280 */     mplew.writeInt(damage);
/* 281 */     mplew.writeInt(monsterIdFrom);
/* 282 */     mplew.write(0);

/* 284 */     return mplew.getPacket();
   }

   public static byte[] summonSkillLink(int cid, int summonoid, int mode) {
/* 288 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 289 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
/* 290 */     mplew.writeShort(SendPacketOpcode.SUMMON_SKILL_LINK.getValue());

/* 292 */     mplew.writeInt(cid);
/* 293 */     mplew.writeInt(summonoid);
/* 294 */     mplew.writeInt(mode);

/* 296 */     return mplew.getPacket();
   }

   public static byte[] spawnDragon(MapleDragon dragon) {
/* 300 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 301 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 303 */     mplew.writeShort(SendPacketOpcode.DRAGON_SPAWN.getValue());
/* 304 */     mplew.writeInt(dragon.getOwner());
/* 305 */     mplew.writeInt((dragon.getPosition()).x);
/* 306 */     mplew.writeInt((dragon.getPosition()).y);
/* 307 */     mplew.write(dragon.getStance());
/* 308 */     mplew.writeShort(0);
/* 309 */     mplew.writeShort(dragon.getJobId());

/* 311 */     return mplew.getPacket();
   }

   public static byte[] removeDragon(int chrId) {
/* 315 */     log.info("调用"+Thread.currentThread().getStackTrace()[1].getMethodName());
/* 316 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 318 */     mplew.writeShort(SendPacketOpcode.DRAGON_REMOVE.getValue());
/* 319 */     mplew.writeInt(chrId);

/* 321 */     return mplew.getPacket();
   }














   public static byte[] moveDragon(MapleDragon dragon, int v169, int tEncodedGatherDuration, Point startPos, Point velPos, List<LifeMovementFragment> moves) {
/* 338 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 340 */     mplew.writeShort(SendPacketOpcode.DRAGON_MOVE.getValue());
/* 341 */     mplew.writeInt(dragon.getOwner());
/* 342 */     PacketHelper.serializeMovementList(mplew, v169, tEncodedGatherDuration, startPos, velPos, moves);

/* 344 */     return mplew.getPacket();
   }

   public static byte[] spawnLittleWhite(MapleLittleWhite lw) {
/* 348 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 350 */     mplew.writeShort(SendPacketOpcode.SPAWN_LITTLEWHITE.getValue());

/* 352 */     mplew.writeInt(lw.getOwner());
/* 353 */     mplew.writeInt(lw.getObjectId());
/* 354 */     mplew.writeInt(lw.getSkillId());
/* 355 */     mplew.write(1);
/* 356 */     mplew.writePos(lw.getPosition());
/* 357 */     mplew.write(0);
/* 358 */     mplew.writeShort(lw.getStance());

/* 360 */     return mplew.getPacket();
   }


   public static byte[] MoveFox(int cid, int oid, int v169, int tEncodedGatherDuration, Point startPos, Point velPos, List<LifeMovementFragment> moves) {
/* 365 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 367 */     mplew.writeShort(SendPacketOpcode.MOVE_LITTLEWHITE.getValue());
/* 368 */     mplew.writeInt(cid);
/* 369 */     mplew.writeInt(oid);
/* 370 */     PacketHelper.serializeMovementList(mplew, v169, tEncodedGatherDuration, startPos, velPos, moves);
/* 371 */     return mplew.getPacket();
   }

   public static byte[] moveLittleWhite(int cid, int oid, Point pos, int stance, List<LifeMovementFragment> move) {
/* 375 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 377 */     mplew.writeShort(SendPacketOpcode.MOVE_LITTLEWHITE.getValue());
/* 378 */     mplew.writeInt(cid);
/* 379 */     mplew.writeInt(oid);
/* 380 */     mplew.writeInt(0);
/* 381 */     mplew.writePos(pos);
/* 382 */     mplew.writeShort(0);
/* 383 */     mplew.writeShort(0);
/* 384 */     PacketHelper.serializeMovementList(mplew, move);

/* 386 */     return mplew.getPacket();
   }

   public static byte[] showLittleWhite(MapleLittleWhite lw) {
/* 390 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 392 */     mplew.writeShort(SendPacketOpcode.REMOVE_LITTLEWHITE.getValue());

/* 394 */     mplew.writeInt(lw.getOwner());
/* 395 */     mplew.writeInt(lw.getObjectId());
/* 396 */     mplew.write(lw.isShow() ? 1 : 2);

/* 398 */     return mplew.getPacket();
   }

   public static byte[] spawnLargeWhite(MapleLittleWhite lw) {
/* 402 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 404 */     mplew.writeShort(SendPacketOpcode.SPAWN_LARGEWHITE.getValue());

/* 406 */     mplew.writeInt(lw.getOwner());
/* 407 */     mplew.writeShort(0);
/* 408 */     mplew.writeInt(12254874);
/* 409 */     mplew.writeShort(4);
/* 410 */     mplew.write(0);
/* 411 */     mplew.writeLong(2L);

/* 413 */     return mplew.getPacket();
   }

   public static byte[] changeLargeWhiteStace(int cid) {
/* 417 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 419 */     mplew.writeShort(SendPacketOpcode.CHANGE_LITTLEWHITE.getValue());
/* 420 */     mplew.writeInt(cid);

/* 422 */     return mplew.getPacket();
   }

   public static byte[] SoulPowerShocked(MapleCharacter player, int oid, int skillid) {
/* 426 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 428 */     mplew.writeShort(SendPacketOpcode.SOULPOWER_SHOCKED.getValue());

/* 430 */     mplew.writeInt(player.getId());
/* 431 */     mplew.writeInt(oid);
/* 432 */     mplew.writeInt(skillid);

/* 434 */     return mplew.getPacket();
   }


   public static byte[] SummonedCrossTheStyx(MapleSummon summon, int type) {
/* 439 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
/* 440 */     mplew.writeShort(SendPacketOpcode.SUMMON_CROSS_THE_STYX.getValue());
/* 441 */     mplew.writeInt(summon.getOwnerId());
/* 442 */     mplew.writeInt(summon.getObjectId());
/* 443 */     mplew.writeInt(type);
/* 444 */     switch (type) {
       case 2:
/* 446 */         mplew.writeInt(Math.min(summon.getCrystalLevel(), 3));
/* 447 */         for (type = 0; type < Math.min(summon.getCrystalLevel(), 3); type++) {
/* 448 */           mplew.writeInt(type + 1);
/* 449 */           mplew.writeInt(summon.getState(type));
         }
         break;
     }


/* 455 */     return mplew.getPacket();
   }








   public static byte[] SummonedDrawEffect(MapleSummon summon, int type) {
/* 466 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 468 */     mplew.writeShort(SendPacketOpcode.SUMMON_DRAW_EFFECT.getValue());
/* 469 */     mplew.writeInt(summon.getOwnerId());
/* 470 */     mplew.writeInt(summon.getObjectId());
/* 471 */     mplew.writeInt(type);
/* 472 */     switch (type) {
       case 3:
/* 474 */         mplew.writeInt(0);
         break;
     }


/* 479 */     return mplew.getPacket();
   }

   public static byte[] SummonedForceMove(MapleSummon summon, int skillid, int skillLevel, Point point) {
/* 483 */     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

/* 485 */     mplew.writeShort(SendPacketOpcode.SUMMON_FORCE_MOVE.getValue());

/* 487 */     mplew.writeInt(summon.getOwnerId());
/* 488 */     mplew.writeInt(summon.getObjectId());
/* 489 */     mplew.writeInt(skillid);
/* 490 */     mplew.writeInt(skillLevel);
/* 491 */     mplew.writePosAsInt(point);

/* 493 */     return mplew.getPacket();
   }
 }


/* Location:              C:\PGX\Server.jar!\tools\packet\SummonPacket.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */